/*
 * JVM_OpcodeInstance.c
 *
 *  Created on: 05.01.2011
 *      Author: Tavin
 */

#include <stdint.h>

#include "JVM_Class.h"
#include "JVM_Opcode.h"
#include "JVM_OpcodeInstance.h"
#include "JVM_StatusCodes.h"

uint16_t JVM_cmd_new()
{
	int16_t index;
	JVM_StackFrame_t * myStackFrame;
	JVM_CP_Class_t *myCpClassInfo;
	JVM_HandleNumber_t  myInstance;


	index=JVM_Opcode_getCodeShort();

	myStackFrame=JVM_Opcode_getActiveStackFrame();

	myCpClassInfo=JVM_CPTable_getClassInfo(myStackFrame->currentCpTable,index);

//	JVM_Class_t * myClass;

//	myClass=myCpClassInfo->classAdress;
//	dataSize=JVM_Class_getInstanceDataSize(myCpClassInfo->classAdress);



	//  GetMem (Handle) for Object;
	myInstance=JVM_Handle_newInstance(myCpClassInfo->classAdress);


	//set Reference on Top of the Stack
	JVM_StackFrame_pushReference(myStackFrame,myInstance);

	return(STCD_OK);
}
